/**
 * provides components which are used to generate automated
 * junit 4 test cases
 */
package org.jprobe.junit;

import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Member;

/**
 * Provides specifications of an implementing
 * test unit case block for (method/constructor)
 * @author Hussain Al-Mutawa
 * @version 1.0
 */
public interface JUnitTestUnitBlockInterface<T extends Member & GenericDeclaration> {
	/** means that the unit test block has to be dealt with by assertion  **/
	public static final int GETTER = 0;
	/** means that the unit test block is a setter which means it returns nothing **/
	public static final int SETTER = 1;
	/** the default timeout for unit test execution **/
	public static final int DEFAULT_TIMEOUT = 1000;
	/** test unit default annotation **/
	public static final String DEFAULT_ANNOTATION = "@Test";
	/** the value of no exception thrown when the member is called **/
	public static final String NO_EXCEPTION = "";
	/** test unit default annotation **/
	public static final String DEFAULT_DOCUMENTATION = "/**\n *\n */";
	/**
	 * gets the thrown exception class, if the
	 * constructor/method throws any by calling the
	 * method/constructor
	 * @return array of exception classes declared as to be thrown
	 * by the method/constructor
	 */
	String[]getThrowsExceptionClasses();
	/**
	 * gets the expected exception to be thrown
	 * by running the
	 * @return
	 */
	String getExpectedException();
	/**
	 * sets the expected exception which is will be thrown
	 * in case some arguments is made for the given member,
	 * this method can be used to build the annotation
	 * declaration of a JUnit 4 Test Case
	 * @param expectedExceptionClass the expected exception
	 */
	void setExpectedExceptionClass(String expectedExceptionClass);
	/**
	 * gets the header of the unit test block, an
	 * example would be like this<br/><code>
	 * <span style='color:grey'>&#64;Test</span><span style='color:green'>[(expected=Exception.class,timeout=1000)]</span>
	 * </code><br/>where the green part is optional
	 * @return the junit 4 test annotation
	 */
	String getAnnotation();
	/**
	 * gets the timeout of running a method/constructor,
	 * normally, 1000ms is added extra to the actual running
	 * of the actual initialized class
	 * @return time out attribute of the test case
	 */
	int getTimeout();
	/**
	 * sets the timeout after which the test should fail
	 * @param timeout the time set to make the test case fail in ms
	 */
	void setTimeout(int timeout);
	/**
	 * gets the type of the unit test block type
	 * which is either <code>{@link JUnitTestUnitBlockInterface#GETTER}</code><br/>
	 * or <code>{@link JUnitTestUnitBlockInterface#SETTER}</code>
	 * @return
	 */
	int getUnitTestBlockType();
	/**
	 * gets the actual testing body of the unit test case block
	 * @return test body code
	 */
	String getTestBody();
	/**
	 * sets the testing body of the unit test case
	 * @param testingBody java code of assertion, etc.
	 */
	void setTestingBody(String testingBody);
	/**
	 * sets the accessible object (method/constructor) to be tested
	 * @param Member the member of the class which is to be tested
	 */
	void setTestingMember(T member);
	/**
	 * gets the Member associated with this testing block
	 * @return method/constructor
	 */
	T getMember();
	/**
	 * gets the name of the method <code>test[name]()</code>
	 * which is required to be unique
	 * @return unit test block method name
	 */
	String getUnitTestCaseName();
	/**
	 * gets the documentation of the unit test block
	 * which will be added to the javadoc api
	 * @return unit test block documentation comments
	 */
	String getDocumentation();
	/**
	 * sets the documentation of the unit test block
	 * @param documentation unit test block documentation comments
	 */
	void setDocumentation(String documentation);
}
